package com.lottoad.android.cronos.http;

import java.util.HashMap;

import android.content.Context;

public class CNLottoAdApiSet {
	
	protected static boolean sIsLive = false;
	protected static final String DOMAIN_LIVE = "http://182.173.191.163:8080/";
	protected static final String DOMAIN_DEV = "http://ad.lcdns.kr/server";//"http://182.173.191.166:8080/SMASolution";
	
	private static HashMap<Integer, String> sMsgURLTbl = null;

	protected static String sAppType = "lottoAd";
	protected static String sLocType = null;
	protected static String sAppVersion = null;
	
	public static final int MSG_SIDO = 1;
	public static final int MSG_GUGUN = 2;
	public static final int MSG_DONG = 3;
	
	public static final int MSG_MEMBER_JOIN = 4;
	
	public static final int MSG_CASHOUT = 5;
	public static final int MSG_NOTIFY = 6;
	public static final int MSG_FAQ = 7;
	public static final int MSG_PARTNER = 8;
	public static final int MSG_WINNER = 9;
	
	public static final int MSG_ISMEMBER = 10;
	
	public static final int MSG_LOTTO = 11;
	public static final int MSG_LOTTO_SAVE = 12;
	
	public static final int MSG_ALL_LIST = 13;
	public static final int MSG_LOTTO_LIST = 14;
	public static final int MSG_REC_LIST = 15;
	
	public static final int MSG_MYPAGE_LIST = 16;
	public static final int MSG_CHANGE_LIST = 17;
	
	public static final int MSG_CALL = 20;
	
	public static final int MSG_JOIN_PUSH = 30;
	
	public static final int MSG_URL_TEST = 31;
	
	public static final int MSG_REQUEST_AD = 1000;
	
	
	/*####### Ben ########*/
	// 개발서버와 실서버 다름!!
	/*protected static final String URL_TEST = "/zipcodeList.action";
	protected static final String URL_SIDO_LIST = "/sidoList.action";
	protected static final String URL_GUGUN_LIST = "/gugunList.action";
	protected static final String URL_DONG_LIST = "/dongList.action";
	protected static final String URL_MEMBER_JOIN = "/setMemberData.action";

	protected static final String URL_CASHOUT = "/setTransferData.action";
	protected static final String URL_NOTIFY_LIST = "/findNoticeList.action";
	protected static final String URL_FAQ_LIST = "/findFaqList.action";
	protected static final String URL_PARTNER_LIST = "/findPartnerList.action";
	protected static final String URL_WINNER_LIST = "/findWinnerList.action";
	
	protected static final String URL_ISMEMBER = "/findIsMember.action";
	
	protected static final String URL_LOTTO = "/adFrameList.action";
	protected static final String URL_LOTTO_SAVE = "/setFrameSend.action";
	
	protected static final String URL_ALL_LIST = "/findAdAllList.action";
	protected static final String URL_LOTTO_LIST = "/findLottoRecList.action";
	protected static final String URL_REC_LIST = "/findAdRecList.action";
	
	protected static final String URL_MYPAGE_LIST = "/findMyPageData.action";
	protected static final String URL_CHANGE_LIST = "/findTransferMemList.action";
	
	protected static final String URL_CALL = "/setAdCallHistory.action";
	
	protected static final String URL_JOIN_PUSH = "/getLottoRecByJoin.action";*/
	
	protected static final String URL_TEST = "/zipcodeList.asp";
	protected static final String URL_SIDO_LIST = "/sidoList.asp";
	protected static final String URL_GUGUN_LIST = "/gugunList.asp";
	protected static final String URL_DONG_LIST = "/dongList.asp";
	protected static final String URL_MEMBER_JOIN = "/setMemberData.asp";

	protected static final String URL_CASHOUT = "/setTransferData.asp";
	protected static final String URL_NOTIFY_LIST = "/findNoticeList.asp";
	protected static final String URL_FAQ_LIST = "/findFaqList.asp";
	protected static final String URL_PARTNER_LIST = "/findPartnerList.asp";
	protected static final String URL_WINNER_LIST = "/findWinnerList.asp";
	
	protected static final String URL_ISMEMBER = "/findIsMember.asp";
	
	protected static final String URL_LOTTO = "/adFrameList.asp";
	protected static final String URL_LOTTO_SAVE = "/setFrameSend.asp";
	
	protected static final String URL_ALL_LIST = "/findAdAllList.asp";
	protected static final String URL_LOTTO_LIST = "/findLottoRecList.asp";
	protected static final String URL_REC_LIST = "/findAdRecList.asp";
	
	protected static final String URL_MYPAGE_LIST = "/findMyPageData.asp";
	protected static final String URL_CHANGE_LIST = "/findTransferMemList.asp";
	
	protected static final String URL_CALL = "/setAdCallHistory.asp";
	
	protected static final String URL_JOIN_PUSH = "/getLottoRecByJoin.asp";
	/* ####### Ben ######## */
	// Added for request ad
	protected static final String URL_REQUEST_AD = "/setadrequest.asp";
	
	
	
	static {
		sMsgURLTbl = new HashMap<Integer, String>();
		sMsgURLTbl.put(MSG_SIDO, URL_SIDO_LIST);
		sMsgURLTbl.put(MSG_GUGUN, URL_GUGUN_LIST);
		sMsgURLTbl.put(MSG_DONG, URL_DONG_LIST);
		sMsgURLTbl.put(MSG_MEMBER_JOIN, URL_MEMBER_JOIN);
		
		sMsgURLTbl.put(MSG_CASHOUT, URL_CASHOUT);
		sMsgURLTbl.put(MSG_NOTIFY, URL_NOTIFY_LIST);
		sMsgURLTbl.put(MSG_FAQ, URL_FAQ_LIST);
		sMsgURLTbl.put(MSG_PARTNER, URL_PARTNER_LIST);
		sMsgURLTbl.put(MSG_WINNER, URL_WINNER_LIST);
		
		sMsgURLTbl.put(MSG_ISMEMBER, URL_ISMEMBER);
		sMsgURLTbl.put(MSG_LOTTO, URL_LOTTO);
		sMsgURLTbl.put(MSG_LOTTO_SAVE, URL_LOTTO_SAVE);
		
		sMsgURLTbl.put(MSG_ALL_LIST, URL_ALL_LIST);
		sMsgURLTbl.put(MSG_LOTTO_LIST, URL_LOTTO_LIST);
		sMsgURLTbl.put(MSG_REC_LIST, URL_REC_LIST);
		
		sMsgURLTbl.put(MSG_MYPAGE_LIST, URL_MYPAGE_LIST);
		sMsgURLTbl.put(MSG_CHANGE_LIST, URL_CHANGE_LIST);
		
		sMsgURLTbl.put(MSG_CALL, URL_CALL);
		sMsgURLTbl.put(MSG_JOIN_PUSH, URL_JOIN_PUSH);
		
		sMsgURLTbl.put(MSG_URL_TEST, URL_TEST);
		
		sMsgURLTbl.put(MSG_REQUEST_AD, URL_REQUEST_AD);
	}

	public static boolean isLive() {
		return sIsLive;
	}

	public static void setIsLive(boolean isLive) {
		sIsLive = isLive;
	}

	public static String getAppType() {
		return sAppType;
	}

	public static void setAppType(String appType) {
		sAppType = appType;
	}

	@SuppressWarnings("unused")
	public static boolean getURL(Context context, int msgId, StringBuilder sBuilder) {
		if (sBuilder != null) {
			String msgUrl = (String) sMsgURLTbl.get(new Integer(msgId));
			if (msgUrl != null) {

				if (sBuilder == null) {
					sBuilder = new StringBuilder();
				}

				if (sIsLive) {
					sBuilder.append(DOMAIN_LIVE);
				} else {
					sBuilder.append(DOMAIN_DEV);
				}
				sBuilder.append(msgUrl);

				sBuilder.append("?platform=").append("Android" + android.os.Build.VERSION.RELEASE);

				return true;
			}
		}

		return false;
	}

	public static String getURL(Context context, int msgId) {
		StringBuilder sBuilder = new StringBuilder();
		if (getURL(context, msgId, sBuilder)) {
			return sBuilder.toString();
		}

		return null;
	}

	public static void setsIsLive(boolean sIsLive) {
		CNLottoAdApiSet.sIsLive = sIsLive;
	}
}